package giit.computerbase.util;

import java.io.File;
import java.util.UUID;

/**
 * User: tum0r
 * Package Name: giit.computerbase.util
 * Time: 2018/11/10 Saturday 23:37:07
 */
public class Application {
    public static final String PATH = Application.class.getClassLoader().getResource(File.separator).getPath();
    public static String INITIALIZE_PASSWORD = null;
    public static final String DATABASE_NAME = "computerbase";
    public static Thread timeOut = null;

    public static final String[][] TABLE = {
            {"organization", "user_type", "user", "activity_type", "activity_information", "file", "history", "login"},
            {"组织", "用户类型", "用户", "活动类型", "活动详细信息", "文件", "操作历史", "登录"}
    };

    public static final String[] CREATE_TABLE = {
            "create table if not exists organization(id char(50) not null,name char(50) not null, primary key(id,name))",
            "create table if not exists user_type(id char(50) not null,name char(50) not null, primary key(id,name))",
            "create table if not exists user(id char(50) not null,name char(50) not null,organization_id char(50) not null,password char(32) not null,user_type_id char(50) not null,state int not null,primary key(name),foreign key (organization_id) references organization(id),foreign key (user_type_id) references user_type(id))",
            "create table if not exists activity_type(id char(50) not null,name char(50) not null, primary key(id,name))",
            "create table if not exists activity_information(id char(50) not null,title char(50) not null primary key,main text not null,contributor char(10) not null,feed_time date not null,activity_type_id char(50) not null,date datetime not null,foreign key (activity_type_id) references activity_type(id))",
            "create table if not exists history(ip text not null,device text,os text,browser text,organization text not null,user_type char(50) not null,user_name char(50) not null,operation text not null,state text not null,time text not null)",
            "create table if not exists login(organization text not null,user_type char(50) not null,user char(50) not null,cookies text not null,time long not null)",
            "create table if not exists register_code(code char(50) not null, primary key(code))"
    };

    public static final String[] COMPUTER_BASE_NAME = {
            "giit_0001",
            "桂林电子科技大学;信息科技学院;大学生计算机创新实践基地"
    };

    public static final String[][] USER_TYPES = {
            {"type_01", "用户"},
            {"type_02", "管理员"}
    };

    public static final String[][] ACTIVITY_TYPES = {
            {"type_01", "普通"},
            {"type_02", "学术科技类"},
            {"type_03", "校级"},
            {"type_04", "省级"},
            {"type_05", "国家级"}
    };

    public static String getUUID() {
        return UUID.randomUUID().toString();
    }

    public static final int FILE_MAX_SIZE = Integer.MAX_VALUE / 1024 / 1024;

    public static Config getConfig() {
        return new Config();
    }
}
